/**
 *
 *@Author:yangwenbo
 *@Date:2021/5/14 19:15
 ***/

const mysql = require('mysql');
const { MYSQL_CONFIG } = require('../config/config');

const db = mysql.createPool(MYSQL_CONFIG);
// db.connect()
function execSQL( sql ) {
    const promise = new Promise( ( resolve, reject ) => {
       db.query(sql, (err, data) => {
           if ( err ) {
               console.error(err);
               reject(err)
               return;
           }
           if ( data ) {
               resolve(data);
           }
       });

    });
    return promise;
}
module.exports = {
    execSQL
}
